package vn.appsmobi.adapter;


import vn.appsmobi.R;
import vn.appsmobi.model.CategoryInfo;
import vn.appsmobi.ui.CategoryListItem;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;

public class CategoryAdapter extends BaseDataAdapter<CategoryInfo>
{
  public CategoryAdapter(Context context, int headerViewCount)
  {
    super(context);
   
  }

  public void bindView(View view, int position, CategoryInfo data)
  {
     /*if (position < this.mHeaderViewCount)
    	 return;
     else           
      if (view instanceof CategoryListItem)
        ((CategoryListItem)view).bind(data);
        */
	  ((CategoryListItem)view).bind(data);
	  Animation animation = null;  
	  //animation = new TranslateAnimation(_metrics.widthPixels/2, 0, 0, 0);
	  animation = new ScaleAnimation((float)1.0, (float)1.0 ,(float)0, (float)1.0);	  
	  animation.setDuration(850);  
	  view.startAnimation(animation);  
	  animation = null; 
  }

  
  
  
  public int getCount()
  {	 
    return super.getCount();
  }

  /*public int getItemViewType(int position)
  {
    if (position < this.mHeaderViewCount)
    	return LIST_ITEM_TYPE_HEADER;
    else
   
    	return LIST_ITEM_TYPE_ITEM;
    
  } */
/*
  public View getView(int position, View convertView, ViewGroup parent)
  {
	
	Log.v("get view" + position);
    if (convertView == null)
    {
      if (position < this.mHeaderViewCount)
      {
    	  convertView = LayoutInflater.from(this.mContext).inflate(R.layout.main_tab_header_view, parent, false);
    	  bindView(convertView, position, null);
      }
        
      if (position >= this.mHeaderViewCount)
      {
    	  convertView = LayoutInflater.from(this.mContext).inflate(R.layout.category_list_item, parent, false);
    	  bindView(convertView, position, (CategoryInfo)getItem(position - this.mHeaderViewCount));
      }  
    }
    
    return convertView;   
  }
*/
/*  public int getViewTypeCount()
  {
    return LIST_ITEM_TYPE_COUNT;
  }
*/
  public boolean isEnabled(int paramInt)
  {
    return true;
    
  }

  public View newView(Context context, CategoryInfo categoryInfo, ViewGroup parent)
  {
	    CategoryListItem item = (CategoryListItem)LayoutInflater.from(this.mContext).inflate(R.layout.category_list_item, parent, false);
	    item.bind(categoryInfo);
	    return item;
  }


}

